/*
package com.audaque.springboot.foshanupload.web.querydsldemo.service.impl;

import com.audaque.springboot.foshanupload.web.querydsldemo.dao.DemoMapper;
import com.audaque.springboot.foshanupload.web.querydsldemo.service.DemoService;
import com.audaque.springboot.foshanupload.web.querydslmodedemo.model.entity.DemoEntity;
import com.audaque.springboot.foshanupload.web.querydslmodedemo.model.entity.QDemoEntity;
import com.querydsl.core.types.Predicate;
import com.querydsl.jpa.impl.JPAQueryFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class DemoServiceImpl implements DemoService {

    @Autowired
    private DemoMapper demoMapper;
    @Autowired
    private JPAQueryFactory jpaQueryFactory;


    @Override
    public List<DemoEntity> findByAgeAndHeight() {
        System.out.println("执行了简单");
        List<DemoEntity> byAgeAndHeight = demoMapper.findByAgeAndHeight(15, 12);
        return byAgeAndHeight==null?null:byAgeAndHeight;
    }

    */
/**
     * 条件查询
     * @return
     *//*

    @Override
    public List<DemoEntity> selectAll() {
        QDemoEntity demoEntity = QDemoEntity.demoEntity;
        //单表获取年龄为10的结果集
        List<DemoEntity> ageList = jpaQueryFactory.selectFrom(demoEntity).where(demoEntity.age.eq(10)).fetch();
        return ageList;
    }

    @Override
    public Iterable<DemoEntity> findAll(Predicate predicate) {
        return demoMapper.findAll(predicate);
    }

    @Override
    public Map<String, Object> page(Predicate predicate, Integer pageNo, Integer pageSize) {
        QDemoEntity demoEntity = QDemoEntity.demoEntity;
        HashMap<String, Object> result = new HashMap<>();
        long count = jpaQueryFactory.select(demoEntity.count()).from(demoEntity).
                where(predicate).fetchOne();
        List<DemoEntity> list = jpaQueryFactory.select(demoEntity).
                from(demoEntity).
                where(predicate).
                orderBy(demoEntity.age.desc()).
                offset((pageNo-1)*pageSize).
                limit(pageSize).
                fetch();
        result.put("content",list);
        result.put("total",count);
        result.put("pageNo",pageNo);
        result.put("pageSize",pageSize);
        result.put("page",count/pageSize+1);
        System.out.println("单表获取分页的结果集:"+result);
        return result;
    }


}
*/
